local zhengbing = fk.CreateSkill({
  name = "js__zhengbing",
  tags = {Skill.Compulsory},
})

zhengbing:addEffect(fk.EventPhaseEnd, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    local yes = false
    for _, id in ipairs(player:getCardIds("h")) do
        local card = Fk:getCardById(id)
        if (card.trueName == "slash" )then
            yes = true
            break
        end
    end
    return target == player and player:hasSkill(zhengbing.name) and player.phase == Player.Draw and
        not player:isKongcheng() and yes
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = table.filter(player:getCardIds("h"), function(id)
        return Fk:getCardById(id).trueName == "slash"
    end)
    local use = room:askToUseVirtualCard(player, {
            name = "iron_chain",
            skill_name = zhengbing.name,
            prompt = "#js__zhengbing",
            cancelable = true,
            extra_data = {
                extraUse = true,
            },
            subcards = cards,
            })
        if not use then
            room:recastCard(cards, player, zhengbing.name)
        else
            for _, id in ipairs(use.tos) do
                if id.chained then
                    room:addTableMark(id, "@@js__zhengbing")
                end
            end
        end
  end,
})

zhengbing:addEffect(fk.ChainStateChanged, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(zhengbing.name) and target:getMark("@@js__zhengbing")~=0 and  #target:getCardIds("he")~=0 and not target.chained
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    if target~=player then
        local card = player.room:askToChooseCard(player, { target = target, flag = "he", skill_name = zhengbing.name})
        player.room:obtainCard(player, card, false, fk.ReasonPrey, player, zhengbing.name)
    end
    player.room:setPlayerMark(target, "@@js__zhengbing", 0)
  end,
})

Fk:loadTranslationTable {
["js__zhengbing"] = "整兵",
[":js__zhengbing"] = "<b>锁定技</b>，摸牌阶段结束时，你将所有【杀】当一张【铁索连环】使用或重铸，因此横置的角色下次重置后，你获得其一张牌。",
["$js__zhengbing1"] = "",
["$js__zhengbing2"] = "",
["#js__zhengbing"] = "整兵：将所有【杀】当一张【铁索连环】使用,取消则重铸这些牌",
["@@js__zhengbing"] = "整兵"
}
return zhengbing